package com.kiki.singer_category.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.kiki.common.annotation.Log;
import com.kiki.common.core.controller.BaseController;
import com.kiki.common.core.domain.AjaxResult;
import com.kiki.common.enums.BusinessType;
import com.kiki.singer_category.domain.SingerCategory;
import com.kiki.singer_category.service.ISingerCategoryService;
import com.kiki.common.utils.poi.ExcelUtil;
import com.kiki.common.core.page.TableDataInfo;

/**
 * 歌手分类Controller
 * 
 * @author 林志毅
 * @date 2025-05-01
 */
@RestController
@RequestMapping("/singer_category/singer_category")
public class SingerCategoryController extends BaseController
{
    @Autowired
    private ISingerCategoryService singerCategoryService;

    /**
     * 查询歌手分类列表
     */
    @PreAuthorize("@ss.hasPermi('singer_category:singer_category:list')")
    @GetMapping("/list")
    public TableDataInfo list(SingerCategory singerCategory)
    {
        startPage();
        List<SingerCategory> list = singerCategoryService.selectSingerCategoryList(singerCategory);
        return getDataTable(list);
    }

    @GetMapping("/getSingerCategoryList")
    public List<SingerCategory> getSingerCategoryList()
    {
        return singerCategoryService.getSingerCategoryList();
    }

    /**
     * 导出歌手分类列表
     */
    @PreAuthorize("@ss.hasPermi('singer_category:singer_category:export')")
    @Log(title = "歌手分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SingerCategory singerCategory)
    {
        List<SingerCategory> list = singerCategoryService.selectSingerCategoryList(singerCategory);
        ExcelUtil<SingerCategory> util = new ExcelUtil<SingerCategory>(SingerCategory.class);
        util.exportExcel(response, list, "歌手分类数据");
    }

    /**
     * 获取歌手分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('singer_category:singer_category:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(singerCategoryService.selectSingerCategoryById(id));
    }

    /**
     * 新增歌手分类
     */
    @PreAuthorize("@ss.hasPermi('singer_category:singer_category:add')")
    @Log(title = "歌手分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SingerCategory singerCategory)
    {
        return toAjax(singerCategoryService.insertSingerCategory(singerCategory));
    }

    /**
     * 修改歌手分类
     */
    @PreAuthorize("@ss.hasPermi('singer_category:singer_category:edit')")
    @Log(title = "歌手分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SingerCategory singerCategory)
    {
        return toAjax(singerCategoryService.updateSingerCategory(singerCategory));
    }

    /**
     * 删除歌手分类
     */
    @PreAuthorize("@ss.hasPermi('singer_category:singer_category:remove')")
    @Log(title = "歌手分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(singerCategoryService.deleteSingerCategoryByIds(ids));
    }
}
